package commonDataStructures;

public class PSingleCollection<E extends Comparable<E>> implements PrimitiveCollection<E>{
	
	E _singelton = null;
	
	@Override
	public void init() {
		_singelton = null; 
		
	}

	@Override
	public void insert(E e) {
		if (_singelton == null){
			_singelton = e;
		}else{
			if (_singelton.compareTo(e)>0){
				_singelton = e;
			}
		}
		
	}

	@Override
	public boolean isEmpty() {
		return (_singelton == null);
	}

	@Override
	public E remove() {
		E tmp = _singelton;
		_singelton = null;
		return tmp;
	}

	@Override
	public int size() {
		return _singelton==null?0:1;
	}
	
}
